/**
 * Created by linxin on 2017/3/11.
 */
import {save} from '../../utils';

export default {
  SETSIDEBAR(states, obj) {
    states.sidebar = obj.sidebar||{};
  },
  SETDEVICE(states, obj) {
    states.device = obj.device||'c';
  },
  SETSIZE(states, obj) {
    states.size = obj.size||'medium';
    save("sidebarSize",states.size)
  },
  SET_SIZE: (state, size) => {
    state.size = size
    save("size",size)
  },
  TOGGLE_SIDEBAR: state => {
    state.sidebar.opened = !state.sidebar.opened
    state.sidebar.withoutAnimation = false
    if (state.sidebar.opened) {
      save("sidebarStatus",1)
    } else {
      save("sidebarStatus",0)
    }
  },
  CLOSE_SIDEBAR: (state, withoutAnimation) => {
    // Cookies.set('sidebarStatus', 0)
    save("sidebarStatus",0)
    state.sidebar.opened = false
    state.sidebar.withoutAnimation = withoutAnimation
  },
  TOGGLE_DEVICE: (state, device) => {
    state.device = device
  }
}
